//
// Created by gxy on 2025/8/31.
//

#include <common.h>

int findRK(ListNode* head,int k) {
    deque<int> q;
    while (head ->next!=nullptr) {
        head=head->next;
        if (q.size()<k) {
            q.push_back(head->val);
        }else {
            q.pop_front();
            q.push_back(head->val);
        }
    }
    return q.front();
}
int main(int argc, char *argv[]) {
    auto head=ListNode::of({1,2,3,4,5,6});
    int res=findRK(head,3);
    std::cout<<res<<std::endl;
    return 0;
}
